<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <title>樱桃销售管理系统 | 登录</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/iCheck/square/blue.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    樱桃销售管理系统
  </div>
  <!-- /.login-logo -->
  <div class="card">
    <div class="card-body login-card-body">
      <p class="login-box-msg">欢迎使用</p>

      <div id="alert" class="alert alert-danger alert-dismissible" style="display: none">
        <button type="button" class="close" id="alertClose">×</button>
        <p id="alertcon"></p>
      </div>


      <div class="form-group has-feedback">
        <input id="user" type="email" class="form-control" placeholder="帐号">
        <span class="fa fa-envelope form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input id="pass" type="password" class="form-control" placeholder="密码">
        <span class="fa fa-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <div class="col-8">
          <div class="checkbox icheck">
            <!--<label>-->
            <!--<input type="checkbox"> Remember Me-->
            <!--</label>-->
          </div>
        </div>
        <!-- /.col -->
        <div class="col-4">
          <button type="submit" id="submit" class="btn btn-primary btn-block btn-flat">登录</button>
        </div>
        <!-- /.col -->
      </div>

    </div>
  </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- iCheck -->
<script src="plugins/iCheck/icheck.min.js"></script>
<script>
    $.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});

    $(function () {

    })

    $('#submit').click (function () {
        var user = $('#user').val();
        var pass = $('#pass').val();
        if (user != null && pass != null){
            $.post(
                'login',
                {
                    user : user,
                    pass : pass
                },
                function (result) {
                    result = JSON.parse(result);
                    if (result.status === 0){
                        $(window).attr('location', '/');
                    }
                    else {
                        $('#alert').show();
                        $('#alertcon').html(result.content);
                    }
                }
            );
        }
    });

    $('#alertClose').click (function () {
        $('#alert').hide();
    });
</script>
</body>
</html>
